package com.vcs.domain;

import java.text.*;
import java.util.*;

import javax.persistence.Entity;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.CascadeType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Id;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "jobseekers")
public class Jobseeker {

	private Long jobseekerId;
	private String firstName;
	private String lastName;
	private String username;
	private String password;
	// contact details
	private String email;
	private boolean gender;
	private long mobileNumber;
	private int currentLocation;
	private int preferredLocation;
	private int nationality;
	
	private int expYears;
	private int expMonths;
	//private int jobCagtegory; 
	private String keySkills;
	// Educational details
	private int highestQualification;
	private String specialization;
	private int yearOfPassing;
	private String institute;
	// name of uploaded resume file.
	private String resumeName;
	private Date resumeUploadDate;
	// added fields
	private String designation;
	private String currentEmployer;
	private String previousEmployer;
	private java.util.Date dateOfBirth;
	// metadata
	private Date profileCreationDate;
	

	public Jobseeker() {
		// TODO Auto-generated constructor stub
	}

	@Id
	@GeneratedValue
	@Column(name = "jobseeker_id")
	public Long getJobseekerId() {
		return jobseekerId;
	}

	public void setJobseekerId(Long jobseekerId) {
		this.jobseekerId = jobseekerId;
	}

	@Column(name = "email")
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "first_name")
	public String getFirstName() {
		return firstName;
	}

	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}

	@Column(name = "last_name")
	public String getLastName() {
		return lastName;
	}

	public void setLastName(String lastName) {
		this.lastName = lastName;
	}

	@Column(name = "username")
	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	@Column(name = "password")
	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	@Column(name = "mobile_number")
	public long getMobileNumber() {
		return mobileNumber;
	}

	public void setMobileNumber(long mobileNumber) {
		this.mobileNumber = mobileNumber;
	}

	@Column(name = "current_location")
	public int getCurrentLocation() {
		return currentLocation;
	}

	public void setCurrentLocation(int currentLocation) {
		this.currentLocation = currentLocation;
	}

	@Column(name = "preferred_location")
	public int getPreferredLocation() {
		return preferredLocation;
	}

	public void setPreferredLocation(int preferredLocation) {
		this.preferredLocation = preferredLocation;
	}

	@Column(name = "nationality")
	public int getNationality() {
		return nationality;
	}

	public void setNationality(int nationality) {
		this.nationality = nationality;
	}

	@Column(name = "gender")
	public boolean isGender() {
		return gender;
	}

	public void setGender(boolean gender) {
		this.gender = gender;
	}

	@Column(name = "exp_years")
	public int getExpYears() {
		return expYears;
	}

	public void setExpYears(int expYears) {
		this.expYears = expYears;
	}

	@Column(name = "exp_months")
	public int getExpMonths() {
		return expMonths;
	}

	public void setExpMonths(int expMonths) {
		this.expMonths = expMonths;
	}
/*
	@Column(name = "job_category")
	public int getJobCagtegory() {
		return jobCagtegory;
	}

	public void setJobCagtegory(int jobCagtegory) {
		this.jobCagtegory = jobCagtegory;
	}
*/
	@Column(name = "key_skills")
	public String getKeySkills() {
		return keySkills;
	}

	public void setKeySkills(String keySkills) {
		this.keySkills = keySkills;
	}

	@Column(name = "highest_qualification")
	public int getHighestQualification() {
		return highestQualification;
	}

	public void setHighestQualification(int highestQualification) {
		this.highestQualification = highestQualification;
	}

	@Column(name = "specialization")
	public String getSpecialization() {
		return specialization;
	}

	public void setSpecialization(String specialization) {
		this.specialization = specialization;
	}

	@Column(name = "year_of_passing")
	public int getYearOfPassing() {
		return yearOfPassing;
	}

	public void setYearOfPassing(int yearOfPassing) {
		this.yearOfPassing = yearOfPassing;
	}

	@Column(name = "institute")
	public String getInstitute() {
		return institute;
	}

	public void setInstitute(String institute) {
		this.institute = institute;
	}

	@Column(name = "designation")
	public String getDesignation() {
		return designation;
	}

	public void setDesignation(String designation) {
		this.designation = designation;
	}

	@Column(name = "current_employer")
	public String getCurrentEmployer() {
		return currentEmployer;
	}

	public void setCurrentEmployer(String currentEmployer) {
		this.currentEmployer = currentEmployer;
	}

	@Column(name = "previous_employer")
	public String getPreviousEmployer() {
		return previousEmployer;
	}

	public void setPreviousEmployer(String previousEmployer) {
		this.previousEmployer = previousEmployer;
	}

	@Column(name = "date_of_birth")
	@Temporal(TemporalType.TIMESTAMP)
	public java.util.Date getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(java.util.Date dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	// A fix for type conversion in date of birth
	public void setDateOfBirth(String dob) {
		DateFormat df = new SimpleDateFormat("dd/MM/yyyy");

		try {
			Date today = df.parse(dob);
			setDateOfBirth(today);//call method
			System.out.println("Today = " + df.format(today));
		} catch (ParseException e) {
			e.printStackTrace();
		}
	}
	
	@Column(name = "resume_name")
	public String getResumeName() {
		return resumeName;
	}
	
	public void setResumeName(String resumeName) {
		this.resumeName = resumeName;
	}
	
	@Column(name = "resume_upload_date")
	public Date getResumeUploadDate() {
		return resumeUploadDate;
	}
	
	public void setResumeUploadDate(Date resumeUploadDate) {
		this.resumeUploadDate = resumeUploadDate;
	}
	
	@Column(name = "profile_creation_date")
	public Date getProfileCreationDate() {
		return profileCreationDate;
	}
	
	public void setProfileCreationDate(Date profileCreationDate) {
		this.profileCreationDate = profileCreationDate;
	}

	@Override
	public String toString() {
		return "Jobseeker [jobseekerId=" + jobseekerId + ", firstName="
				+ firstName + ", lastName=" + lastName + ", username="
				+ username + ", password=" + password + ", email=" + email
				+ ", gender=" + gender + ", mobileNumber=" + mobileNumber
				+ ", currentLocation=" + currentLocation
				+ ", preferredLocation=" + preferredLocation + ", nationality="
				+ nationality + ", expYears=" + expYears + ", expMonths="
				+ expMonths + ", keySkills=" + keySkills
				+ ", highestQualification=" + highestQualification
				+ ", specialization=" + specialization + ", yearOfPassing="
				+ yearOfPassing + ", institute=" + institute + ", resumeName="
				+ resumeName + ", resumeUploadDate=" + resumeUploadDate
				+ ", designation=" + designation + ", currentEmployer="
				+ currentEmployer + ", previousEmployer=" + previousEmployer
				+ ", dateOfBirth=" + dateOfBirth + ", profileCreationDate="
				+ profileCreationDate + "]";
	}
	

}